package com.vertexnet.realestatenet.model.bean;

// Generated May 22, 2012 8:11:57 AM by Hibernate Tools 3.4.0.CR1

import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

/**
 * Agent generated by hbm2java
 */
@Entity
@Table(name = "agent", catalog = "real_estate_net")
public class Agent implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	private Integer agentId;
	private String address;
	private String name;
	private int commisionPercent;
	private String mobile;
	private String phone;
	private Set<Payment> payments = new HashSet<Payment>(0);

	public Agent() {
	}

	public Agent(String name, int commisionPercent) {
		this.name = name;
		this.commisionPercent = commisionPercent;
	}

	public Agent(String address, String name, int commisionPercent, String mobile, String phone, Set<Payment> payments) {
		this.address = address;
		this.name = name;
		this.commisionPercent = commisionPercent;
		this.mobile = mobile;
		this.phone = phone;
		this.payments = payments;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "agent_id", unique = true, nullable = false)
	public Integer getAgentId() {
		return this.agentId;
	}

	public void setAgentId(Integer agentId) {
		this.agentId = agentId;
	}

	@Column(name = "address")
	public String getAddress() {
		return this.address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@Column(name = "name", nullable = false, length = 25)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "commision_percent", nullable = false)
	public int getCommisionPercent() {
		return this.commisionPercent;
	}

	public void setCommisionPercent(int commisionPercent) {
		this.commisionPercent = commisionPercent;
	}

	@Column(name = "mobile", length = 12)
	public String getMobile() {
		return this.mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	@Column(name = "phone", length = 12)
	public String getPhone() {
		return this.phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "agent")
	@NotFound(action = NotFoundAction.IGNORE)
	public Set<Payment> getPayments() {
		return this.payments;
	}

	public void setPayments(Set<Payment> payments) {
		this.payments = payments;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Agent) {
			Agent agent = (Agent) obj;
			return new EqualsBuilder()
				.append(this.getAgentId(), agent.getAgentId())
				.append(this.getName(), agent.getName())
				.isEquals();
		}
		return false;
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder()
			.append(this.getAgentId())
			.append(this.getName())
			.toHashCode();
	}

	@Override
	public String toString() {
		return this.getName();
	}
}
